<?php
//filename : m_requeststu.php

require_once APPPATH.'models/gnc_db_mysql'.EXT;

class M_REQUESTSTU extends Gnc_db_mysql {
	protected $data_source	= 'stu_t_request';
	
	//agar saat data diedit, nip_pe_request dan status tidak ditampilkan
	public function get_single($record) {
	
	    $myquery = "select id,kategori_tugas,perihal_tugas,lokasi_tugas, dt_berangkat,  dt_kembali, nama_bertugas,keterangan from stu_t_request"; 
		if (!is_array($record)) {
			$record = array('id' => NULL);
		}
		//bagian yang dioverride
		$metadata = $this->get_metadata($myquery);
		
		$data['n_all_records'] = $this->db->count_all($this->data_source);
		$data['first'] = current($this->db->query('SELECT id,kategori_tugas,perihal_tugas,lokasi_tugas, dt_berangkat,  dt_kembali, nama_bertugas,keterangan FROM '.$this->data_source.' ORDER BY `'.key($record).'` ASC LIMIT 1')->result_array());
		$data['previous'] = current($this->db->query('SELECT id,kategori_tugas,perihal_tugas,lokasi_tugas, dt_berangkat,  dt_kembali, nama_bertugas,keterangan FROM '.$this->data_source.' WHERE `'.key($record).'` < '.$this->db->escape(current($record)).' ORDER BY `'.key($record).'` DESC LIMIT 1')->result_array());
		$data['current'] = current($this->db->query('SELECT id,kategori_tugas,perihal_tugas,lokasi_tugas, dt_berangkat,  dt_kembali, nama_bertugas,keterangan FROM '.$this->data_source.' WHERE '.$this->compile_where($record))->result_array());
		$data['next'] = current($this->db->query('SELECT id,kategori_tugas,perihal_tugas,lokasi_tugas, dt_berangkat,  dt_kembali, nama_bertugas,keterangan FROM '.$this->data_source.' WHERE `'.key($record).'` > '.$this->db->escape(current($record)).' ORDER BY `'.key($record).'` ASC LIMIT 1')->result_array());
		$data['last'] = current($this->db->query('SELECT id,kategori_tugas,perihal_tugas,lokasi_tugas, dt_berangkat,  dt_kembali, nama_bertugas,keterangan FROM '.$this->data_source.' ORDER BY `'.key($record).'` DESC LIMIT 1')->result_array());
		$result		= compact('metadata', 'data');
		return $result;
	}
   
}

?>
